Skip to content

Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs#29758

Open
louis-pie wants to merge 1 commit into
trinodb:masterfrom
louis-pie:iceberg-rest-oauth-token-exchange
Open

Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs#29758
louis-pie wants to merge 1 commit into
trinodb:masterfrom
louis-pie:iceberg-rest-oauth-token-exchange

Conversation

@louis-pie

@louis-pie louis-pie commented Jun 4, 2026

Copy link
Copy Markdown

Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs.

Description

This change adds one optional Trino OAuth2 setting:

http-server.authentication.oauth2.access-token-extra-credential-name

When set, the OAuth2 authenticator stores the authenticated access token in Identity.extraCredentials under both the configured name and a tamper-proof internal$authenticated:<name> key. The Iceberg REST connector reads only the authenticated key, preventing clients from spoofing OAuth2 session credentials.

Iceberg REST catalogs configured with:

iceberg.rest-catalog.session=USER
iceberg.rest-catalog.security=OAUTH2

use the authenticated session extra credential named token (for direct forwarding) or credential (for token exchange) when static catalog OAuth2 credentials are not configured.

Security model

  • New SPI utility (ExtraCredentials): formalizes the internal$ prefix convention for server-placed credentials. Clients submitting internal$-prefixed extra credentials are rejected at the coordinator.
  • Authenticated credential precedence: if a client also submits an extra credential with the same name, the server-authenticated value wins.
  • Worker credential stripping: internal$-prefixed credentials are filtered from TaskUpdateRequest so they never leave the coordinator.

Per-user catalog caching

When session=USER, the factory caches a RESTSessionCatalog per distinct set of authenticated credentials. Cache entries expire based on the JWT exp claim (parsed with lightweight base64/string matching — no jjwt dependency) or fall back to the configurable iceberg.rest-catalog.session-timeout. The cache is bounded to 1000 entries with expired-entry eviction.

Two supported authorization patterns

  • Direct token forwarding: the REST catalog validates and authorizes the Trino user's access token directly. Configure with access-token-extra-credential-name=token.
  • Token exchange: the Iceberg REST OAuth2 client uses the authenticated token as the credential for its OAuth2 flow with the configured server. Trino does not perform the exchange itself. Configure with access-token-extra-credential-name=credential.

Not a breaking change

The new coordinator setting is unset by default. Existing OAuth2 authentication and Iceberg REST catalog configurations behave as before. Static iceberg.rest-catalog.oauth2.token and iceberg.rest-catalog.oauth2.credential values continue to take precedence over session credentials.

Module-level validation

  • session=USER requires security=OAUTH2 (rejects at startup otherwise).
  • security=OAUTH2 without session=USER requires a static credential or token (previously failed at query time with an opaque Iceberg error).

Additional context and related issues

Trino stores and forwards the authenticated access token. It does not perform token exchange itself — that responsibility belongs to the Iceberg REST OAuth2 client and the catalog's authorization server.

The SIGV4 and GOOGLE security modes are unaffected; they use the existing no-op security properties provider.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text:

## Iceberg
* Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs.

@github-actions github-actions Bot added docs iceberg Iceberg connector labels Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@louis-pie louis-pie force-pushed the iceberg-rest-oauth-token-exchange branch 3 times, most recently from 7e98272 to b3ad793 Compare June 5, 2026 20:44
@lucianogreiner

Copy link
Copy Markdown

Duplicated with #29538

@louis-pie louis-pie changed the title Support OAuth2 token propagation for Iceberg REST catalog Allow OAuth2-authenticated user tokens to be used with Iceberg REST catalogs. Jun 8, 2026
@louis-pie louis-pie force-pushed the iceberg-rest-oauth-token-exchange branch from b3ad793 to 666d29e Compare June 8, 2026 11:32
@louis-pie louis-pie changed the title Allow OAuth2-authenticated user tokens to be used with Iceberg REST catalogs. Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs. Jun 8, 2026
@louis-pie louis-pie force-pushed the iceberg-rest-oauth-token-exchange branch from 666d29e to 4756b3c Compare June 8, 2026 14:12
@louis-pie louis-pie changed the title Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs. Allow OAuth2 authenticated user tokens to be used with Iceberg REST catalogs Jun 8, 2026
@louis-pie louis-pie force-pushed the iceberg-rest-oauth-token-exchange branch from 4756b3c to 7d10652 Compare June 12, 2026 13:25
Store the authenticated access token under a tamper-proof
internal$authenticated: extra credential key. Iceberg REST catalogs
with session=USER and security=OAUTH2 use the authenticated `token`
or `credential` for per-user REST catalog requests.

Cache a RESTSessionCatalog per user with JWT exp-based TTL. Strip
internal credentials from worker task updates. Reject client-submitted
internal$ credentials at the coordinator.
@louis-pie louis-pie force-pushed the iceberg-rest-oauth-token-exchange branch from 7d10652 to 5432c5a Compare June 12, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs iceberg Iceberg connector

Development

Successfully merging this pull request may close these issues.

2 participants